/*
 * Class:CEMAgenda
 * 
 * Description: This class implements the methods needed for the initialization
 * of the agenda properties that will be displayed in the GUI. It lets you initialize different
 * agendas with methods for adding, deleting, (editing) and gathering information on an event.
 * 
 * Version: 1.0 - Nikolay Neshev, Sonny Guenette - 28-10-2011
 * 		Initial implementation
 * Version: 1.1 - M-A Lavoie - 2011-12-04
 * 	    Removed unused getDate method.
 *      Renamed methods to lowerCase.
 * Version : 1.2 - F-X Frenette - 2011-12-09
 * 		Modify event list management functions
 * 		Modify comments for JAVADOC
 *      
 * Copyright GPP - Genuine People Personality inc
 * 
 */

package calendarEventManager;

import java.lang.String;
import java.util.*;

public class CEMAgenda implements CEMConstants {
	//**************************************************************
	// MODAL VARIABLES
	//**************************************************************
	private int m_nAgendaId;
	/** The current agenda's name*/
	private String m_sAgendaName;
	/** The current agenda's colour to be displayed on the calendar*/
	private int m_nAgendaColour;
	/** The current agenda's events*/
	private List<CEMEvent> m_oEventsList;
	/** If the agenda is activated in the interface*/
	private boolean m_bIsActivated;

	//**************************************************************
	// Method: CEMAgenda
	// Description: Class constructor
	//**************************************************************
	/**
	 * @param p_nAgendaId
	 * @param p_sAgendaName
	 * @param p_nAgendaColour
	 */
	public CEMAgenda(Integer p_nAgendaId, String p_sAgendaName, Integer p_nAgendaColour){
			m_nAgendaId 	= p_nAgendaId;
			m_sAgendaName	= p_sAgendaName;
			m_nAgendaColour = p_nAgendaColour;
			m_oEventsList	= new ArrayList<CEMEvent>();

	} // CEMAgenda()	

	//**************************************************************
	// Method: addEvent
	// Description: Adds an event to the current object's event list
	//**************************************************************
	/**
	 * @param p_oNewEvent
	 * 		Event to be added
	 */
	public void addEvent(CEMEvent p_oNewEvent){
		m_oEventsList.add(p_oNewEvent);
	} // addEvent()
	
	//**************************************************************
	// Method: RemoveEvent
	// Description: Removes an event from the current object's event list
	//**************************************************************	
	/**
	 * @param p_nEventId
	 * 		The event's Id
	 * @return int
	 * 		Returns 0 if the removal was successful
	 */
	public int deleteEvent(int p_nEventId){
		int nRc = CEM_RETURN_CODE_ERROR;
		
		for(CEMEvent oWork : m_oEventsList){
			if(oWork.getEventId() == p_nEventId){
				//delete from the list
				m_oEventsList.remove(oWork);
				nRc = CEM_RETURN_CODE_OK;
				break;
			}
		}
		return nRc;
	} // deleteEvent()
	
	//**************************************************************
	// Method: getEvent
	// Description:
	//**************************************************************		
	/**
	 * @param p_nEventId
	 * 		The event's Id
	 * @return CEMEvent
	 * 		Returns the object or null if not found
	 */
	public CEMEvent getEvent(int p_nEventId){
		CEMEvent oEvent = null;
		
		for(CEMEvent oWork : m_oEventsList){
			if(oWork.getEventId() == p_nEventId){
				oEvent = oWork;
				break;
			}
		}
		
		return oEvent;
	} // GetEvent()
	

	//**************************************************************
	// Method: SetAgendaName
	// Description: Sets the name of the agenda
	//**************************************************************
	/**
	 * @param p_sAgendaName
	 * 		The new agenda name
	 */
	public void setAgendaName(String p_sAgendaName){
		m_sAgendaName = p_sAgendaName;
	}// setAgendaName
	

	//**************************************************************
	// Method: SetAgendaColour
	// Description: Sets the name of the agenda
	//**************************************************************
	/**
	 * @param p_nColourID
	 * 		New colour ID
	 */
	public void setAgendaColour(int p_nAgendaColour){
		m_nAgendaColour = p_nAgendaColour;
	} // set AgendaColour()	

	//**************************************************************
	// Method: setAgendaId
	// Description: Sets the Id of the agenda
	//**************************************************************
	/**
	 * @param p_nAgendaId
	 * 		The agenda Id
	 */
	public void setAgendaId(int p_nAgendaId){
		m_nAgendaId = p_nAgendaId;
	}// setAgendaId()
	
	//**************************************************************
	// Method: getAgendaName
	// Description: Returns the agenda's name
	//**************************************************************
	/**
	 * @return String
	 * 		Agenda's name
	 */
	public String getAgendaName(){
		return m_sAgendaName;
	} // getAgendaName()	

	//**************************************************************
	// Method: getAgendaColour
	// Description: Returns the agenda's colour
	//**************************************************************
	/**
	 * @return int
	 * 		Agenda's colour
	 */
	public int getAgendaColour(){
		return m_nAgendaColour;
	} // getAgendaColour()	
	
	//**************************************************************
	// Method: GetAgendaId
	// Description: Gets the Id of the agenda
	//**************************************************************
	/**
	 * @return int
	 * 		Agenda's colour
	 */
	public int getAgendaId(){
		return m_nAgendaId;
	}// getAgendaId()
	
	//**************************************************************
	// Method: getEventsList
	// Description: Gets the list of event for the current agenda
	//**************************************************************
	/**
	 * @return List<CEMEvent>
	 * 		List of the events
	 */
	public List<CEMEvent> getEventsList() {
		return m_oEventsList;
	} // getEventsList()
	
	//**************************************************************
	// Method: setEventsList
	// Description: Loading of the list of events
	//**************************************************************
	/**
	 * @param p_oEventsList
	 * 		List of events to be set in the agenda
	 */
	public void setEventsList(List<CEMEvent> p_oEventsList) {
		m_oEventsList = p_oEventsList;
	} // setEventsList()
	
	//**************************************************************
	// Method: isActivated
	// Description: Getter for isActivated
	//**************************************************************
	/**
	 * @return boolean
	 * 		True if the agenda is activated
	 */
	public boolean isActivated() {
		return m_bIsActivated;
	} // isActivated()

	//**************************************************************
	// Method: setActivated
	// Description: Setter for isActivated
	//**************************************************************
	/**
	 * @param p_bIsActivated
	 * 		Activate(true) or deactivate(false) the current agenda
	 */
	public void setActivated(boolean p_bIsActivated) {
		this.m_bIsActivated = p_bIsActivated;
	} // setActivated()
	
} // Class CEMAgenda
